package level.editor.state;

import level.editor.command.Command;
import level.editor.command.RequiresOutput;
import level.editor.main.LevelOutput;
import level.state.StateHandler;

public class UpdateStateCommand extends Command implements RequiresOutput
{
	private StateModule module;

	public UpdateStateCommand(StateModule module)
	{
		super("LevelModule");
		this.module = module;
	}

	public void execute(LevelOutput levelOutput)
	{
		levelOutput.setViewBorder((module.isModified() ? "*" : "")
				+ (module.getState().getFile() == null ? "New Level.xml"
						: module.getState().getFile().getName()));

		levelOutput.setDimension(StateHandler.calculateMax(module.getState()));
		levelOutput.setState(module.getState());
		levelOutput.repaint();
	}
}
